<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        img{
            position: absolute;
            left: 0;
            top: 0;
            
        }
    </style>
</head>
<body>
    <img src="./img.jpg" alt="超人" width="100px">
</body>
<script>
    var potoch = document.querySelector('img')
    var targerX = 0
    var targerY = 0
    var lerderX = 0
    var lerderY = 0
    document.onclick = function(event){
        targerX = event.clientX - potoch.offsetWidth/2
        targerY = event.clientY - potoch.offsetHeight/2
    }
    function fn() {
        lerderX = lerderX + (targerX - lerderX)/10
        lerderY = lerderY + (targerY - lerderY)/10
        potoch.style.left = lerderX + 'px'
        potoch.style.top = lerderY + 'px'
    }
    setInterval(fn, 30);
</script>
</html>